import type { StrokeStyle } from '../../consts.js';
import type { IVec } from '../../utils/vec.js';
import type { ISurfaceElement } from '../surface-element.js';

export enum ConnectorMode {
  Straight,
  Orthogonal,
  Curve,
}

// at least one of id and position is not null
// both exists means the position is relative to the element
export type Connection = {
  id?: string;
  position?: IVec;
};

export interface Controller {
  x: number;
  y: number;
  // If this value is true, it indicates that the point was generated by the user dragging
  customized?: boolean;
}

export interface IConnector extends ISurfaceElement {
  type: 'connector';

  mode: ConnectorMode;
  stroke: string;
  strokeWidth: number;
  strokeStyle: StrokeStyle;
  // https://github.com/rough-stuff/rough/wiki#roughness
  roughness?: number;
  rough?: boolean;
  source: Connection;
  target: Connection;

  // absolute canvas point
  controllers: Controller[];

  path: IVec[];
  absolutePath: IVec[];
}
